#ifndef __TASKQUEUE_H__
#define __TASKQUEUE_H__

#include <queue>
#include <functional>
#include "Cond.h"

namespace tp
{

class TaskQueue
{
    typedef std::function<void()> Func;
public:
    TaskQueue(int size = 10);
    ~TaskQueue();

    void push(const Func&);
    Func pop();

    bool full();
    bool empty();

    void wakeup();
private:
    int _size;
    std::queue<Func> _que;
    tp::MutexLock _mutex;
    tp::Cond _notFull; 
    tp::Cond _notEmpty;
    bool _isRunning;
};

}

#endif
